﻿@{
    ViewBag.BBFaBuView = "active";
    ViewBag.Title = "发布填报";
    Layout = "~/Views/Shared/_layout_wenlvting.cshtml";
}

<div class="tianbao_xinxi">
    <div class="biao_one biao_hight">
        <span>报表名称</span>
        <div class="biao_name">
            <input type="text" placeholder="请输入报表名称" class="gao" v-model="bb_name">
        </div>
    </div>
    <div class="biao_one biao_hight">
        <span>填报类型</span>
        <div class="biao_name">
            <select class="sel_width03" onchange="change_dttype();" id="sel_bbtype" v-model="leixing">
                <option value="1">月报</option>
                <option value="2">年报</option>
            </select>
        </div>
    </div>
    <div class="biao_one biao_hight">
        <span>报表日期</span>
        <div class="biao_name" id="div_bbriqi">
            <input type="text" id="inp_bbriqi" placeholder="yyyy-mm-dd" class="gao">
        </div>
    </div>
    <div class="biao_one ">
        <span>设计范围</span>

    </div>
    <div class="biao_name border_biao" style="max-height:200px;overflow-y:auto;height:200px;">
        <el-tree :data="lisjd"
                 show-checkbox
                 node-key="id"
                 ref="mytree"
                 :default-expanded-keys="[10002205]"
                 :default-checked-keys="[10002205]"
                 :props="defaultProps">
        </el-tree>
    </div>
    <div class="kong5"></div>
    <div class="biao_one biao_hight">
        <span>短信通知酒店</span>
        <div class="biao_name">
            <el-switch v-model="is_duanxin"
                       active-color="#13ce66"
                       inactive-color="#DCDFE6">
            </el-switch>
        </div>
    </div>
    <div class="biao_one biao_hight">
        <span>开始日期</span>
        <div class="biao_name"><input type="text" id="inp_kaishiriqi" placeholder="yyyy-mm-dd" class="gao"></div>

        <div class="kong5"></div>
        <div class="biao_one biao_hight">
            <span>截止日期</span>
            <div class="biao_name"><input type="text" id="inp_jieshuriqi" placeholder="yyyy-mm-dd" class="gao"></div>

        </div>
    </div>
    <div class="biao_one biao_hight">
        <button v-on:click="BBFaBuP">发布</button>
    </div>
</div>
<div class="release_hotel">
    <div class="pull_name">已发布报表</div>
    <div class="hotel_details" style="width:auto !important;">
        <table class="table table-striped table-hover">
            <thead>
                <tr>
                    <td>编号</td>
                    <td>类型</td>
                    <td>报表日期</td>
                    <td>报表名称</td>
                    <td>发布人</td>
                    <td>发布时间</td>
                    <td>开始时间</td>
                    <td>结束时间</td>
                    <td>发送短信</td>
                </tr>
            </thead>
            <tbody>
                <tr v-for="(item,index) in lisfb">
                    <td>{{item.id}}</td>
                    <td>{{item.leixing_str}}</td>
                    <td>{{item.bb_riqi_str}}</td>
                    <td>{{item.bb_name}}</td>
                    <td>{{item.fabu_ren}}</td>
                    <td>{{item.fabu_shijian_str}}</td>
                    <td>{{item.tianbao_kaishi_str}}</td>
                    <td>{{item.tianbao_jieshu_str}}</td>
                    <td>{{item.is_duanxin_str}}</td>
                </tr>
            </tbody>
        </table>
        <div style="text-align:center;margin-top:20px; margin-bottom:20px;" v-html="pageHtml"></div>
        <div v-if="msg!=''" style="text-align:center;margin-top:20px; margin-bottom:20px; color:gray">{{msg}}</div>
    </div>

</div>

<script>

    var vm = new Vue({
        el: '#app',
        data: {
            lisjd: @Html.Raw(ViewBag.lisjd),
            defaultProps: {
                children: 'children',
                label: 'label'
            },
            pageHtml: "",
            msg: "",
            lisfb: [],
            is_duanxin: false,
            bb_name: "",
            leixing:1,

        },
        methods: {
            BBFaBuP: function () {
                var pa = {};
                var res = this.$refs.mytree.getCheckedKeys(true);
                pa.bb_name = vm.bb_name;
                pa.is_duanxin = vm.is_duanxin;
                pa.aid_json = JSON.stringify(res);
                pa.leixing = vm.leixing;
                pa.bb_riqi_str = $("#inp_bbriqi").val();
                pa.tianbao_kaishi_str = $("#inp_kaishiriqi").val();
                pa.tianbao_jieshu_str = $("#inp_jieshuriqi").val();
                $.post("/WenLvTing/BBFaBuP", pa, function (res) {
                    alert(res.msg);
                    if (res.code > 0) {
                        location.reload();
                    }
                })

            },

        }
    })

    $(function () {
        GetBBFaBuP(-2);
        laydate.render({
            elem: '#inp_kaishiriqi'
            , type: 'date'
        });
        laydate.render({
            elem: '#inp_jieshuriqi'
            , type: 'date'
        });
        laydate.render({
            elem: '#inp_bbriqi'
            , type: 'month'
        });
    });
    function GetBBFaBuP(init, pageIndex, pageSize) {
        if (init == -2) {
            vm.msg = "";
            pageIndex = 1;
            pageSize = 10;
        }
        var pa = { pageIndex: pageIndex, pageSize: pageSize };
        $.post("/WenLvTing/GetBBFaBuP", pa, function (res) {
            vm.pageHtml = res.pageHtml;
            vm.lisfb = res.lisfb;
            if (vm.lisfb.length <= 0) {
                vm.msg = "没有查询到任何数据！";
            }
            else {
                vm.msg = "";
            }
        });
    }
    function change_dttype() {
        $("#inp_bbriqi").remove();
        $("#div_bbriqi").html('<input id="inp_bbriqi" type="text" placeholder="请选择报表时间" class="gao">');
        var bbtype = $("#sel_bbtype option:selected").val();
        if (bbtype == -1) {
            laydate.render({
                elem: '#inp_bbriqi'
                , type: 'date'
            });
        }
        else if (bbtype == 1) {
            laydate.render({
                elem: '#inp_bbriqi'
                , type: 'month'
            });
        }
        else if (bbtype == 2) {
            laydate.render({
                elem: '#inp_bbriqi'
                , type: 'year'
            });
        }
    }
</script>
